package cn.com.nes.site.controller.crm.customer;

import cn.com.nes.site.entity.PageData;
import cn.com.nes.site.entity.vo.crm.archive.GetCustomerArchiveDetailVO;
import cn.com.nes.site.entity.vo.crm.archive.SaveCustomerArchiveVO;
import cn.com.nes.site.service.crm.customer.CustomerArchiveService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * 客户档案
 */
@Slf4j
@Controller
@RequestMapping("/v2/crm/archive")
public class CustomerArchiveController {
    @Resource
    private CustomerArchiveService customerArchiveService;

    @ApiOperation("保存客户档案")
    @RequestMapping(value = "/saveCustomerArchive", method = RequestMethod.POST)
    public @ResponseBody PageData saveCustomerArchive(@RequestBody @Validated SaveCustomerArchiveVO vo) throws Exception {
        log.debug("销售 - 保存客户档案");
        return customerArchiveService.saveCustomerArchive(vo);
    }

    @ApiOperation("查询档案详情")
    @RequestMapping(value = "/getArchivesDetail", method = RequestMethod.GET)
    public @ResponseBody PageData getArchivesDetail(@Validated GetCustomerArchiveDetailVO vo) throws Exception {
        return customerArchiveService.getCustomerArchiveDetail(vo, 1); // 1-查询安装工单信息
    }
}
